#include"tcpserver.hpp"
#include"protocol.hpp"
#include"NetCal.hpp"
int main(int argc,char* argv[])
{
    //格式:./main port
    if(argc!=2)
    {
        //格式输入错误
        std::cout<<"格式输入错误,应该为:./main port"<<std::endl;
        exit(0);
    }
    std::unique_ptr<NetCal> n=std::make_unique<NetCal>();
    std::unique_ptr<Protocol> p=std::make_unique<Protocol>([&n](Request& q)->Response{return n->Handler(q);});
    std::unique_ptr<tcpserver> t=std::make_unique<tcpserver>(std::stoi(argv[1]),
        [&p](std::shared_ptr<Socket>& sock,Addr& client)
        {
            p->GetRequest(sock,client);
        });
    t->Start();
    return 0;
}